package com.tarena.day0924;

public class Rect {
	int x;
	int y;
	int width;
	int height;
	public Rect(int x,int y,int w,int h){
		this.x=x;
		this.y=y;
		width=w;
		height=h;
	}
	public Rect(int x,int y,int w){
		this(x,y,w,w);//this()只能在构造器中，且只能写在构造器的第一排
	}
	public void setLocation(int x,int y){
		this.x=x;
		this.y=y;
	}
	public void setLocation(int x){
		this.x=x;
		this.y=x;
	}
	public void setSize(int w,int h){
		height=h;
		width=w;
	}
	public double moveTo(int x,int y){
		int dx=this.x-x;
		int dy=this.y-y;
		double dis=Math.sqrt(dx*dx+dy*dy);
		this.setLocation(x,y);
		return dis;
	}
	public String toString(){
		return x+","+y+","+width+","+height;
	}
}
